<?php

namespace lib;

class Life
{
    public static $error = '';

    public static function getCity($ip)
    {
        $api = "http://ip.taobao.com/service/getIpInfo.php";

        $curl = new \lib\HttpLib(['method'=> 'GET', 'params'=> ['ip'=> $ip]]);
        $ret = $curl->request($api);
        if ($ret->result === false) {
            return false;
        }
        $json = $ret->json;
        if ($json->code !== 0) {
            return false;
        }
        return $json->data;
    }
}
